var TheTableControl;

function initPage(){
	//AjaxAction.call("groupAccountAction.loadGroupAccount", 1, 1);
	//PagingBar.doAction("tabNav");
	InitTableControl();
}

/**初始化数据列表空间**/
function InitTableControl(){
	TheTableControl=new TableController('TheTableControl');
	TheTableControl.objTable=document.all.t_data;
	TheTableControl.OnAfterRowSelected=afterSelectTheRow;
	if(TheTableControl.Count()>0)
	{
		//TheTableControl.SelectARow(0);
	}else{
		initButtonStatus();
	}
}

/**根据选择的数据行的状态动态改变功能菜单的有效性**/
function afterSelectTheRow()
{
	disableTD(document.all.deletePhotoLib);
}

/**初始化数据列表之后显示功能菜单的有效性**/
function initButtonStatus()
{
	if (TheTableControl.Count()<1)
	{   
		disableTD(document.all.deletePhotoLib);
	}else
	{   
		enableTD(document.all.deletePhotoLib);		
	}
}

/**===============START:用户事件代码==================**/
/**显示操作的图片库下面的图片**/
function showPhotoList(aid){
	window.location.href="./portal/photo/photolist.jsp?aid=" + aid;
}
/**新增加一个图片库**/
function addNewPhotoLib(){	
	PopDivUp(1);
}

/**修改一个图片库**/
function editPhotoLib(aid){	
	window.location.href="./photosetedit.jsp?aid="+aid;
	
}


/**查询图片库**/
function queryPhotoLib(){
	PopDivUp(3);
}
/**删除选定的图片库**/
function deletePhotoLib(aid){
	if( confirm( "您确实要删除整个图片专辑吗？" ) )
	{		
		AjaxAction.syncCall('photoAction.deletePhotoSpecial',aid);
		window.location.href = "./myhome.jsp";
	}else{
		return;
	}	
}
/**删除选定的图片库**/
function deletePhotoLibSpec(aid){
	if( confirm( "您确实要删除整个图片专辑吗？" ) )
	{		
		AjaxAction.syncCall('photoAction.deletePhotoSpecial',aid);
		window.location.href = "./photospecial.jsp";
	}else{
		return;
	}	
}

function deletePhotoLibBt(){
	var obj = document.getElementsByName('checkbox222');
	var objLen = obj.length;
	var i;
	var j = 0;
	var str = "";
	
	for(i=0; i<objLen; ++i){
		if(obj[i].checked==true){		
			str = str + obj[i].value + ";";
			++j;
		}
	}	
	
	if(j==0){
		alert("请选择要删除的专辑.");
		return;
	}
	

	if( confirm( "您确实要删除所选图片专辑吗？" ) )
	{		
		AjaxAction.syncCall('photoAction.deleteSelectSpecial',str);
		window.location.href = "photo.com";
	}else{
		return;
	}	
}
/** 专辑类别管理 **/
function manageCatalog(){
	//PopDivUp(4);
}

/*** 新建一个类别 **/
function createType(){	
	PopDivUp(5);
}

/** 删除一个类别 **/
function deleteType(){
	if( confirm( "您确实要删除这个类别中所包含的所有图片吗？" ) )
	{		
	//	AjaxAction.syncCall('photoAction.deletePhotoSpecial',aid);
	//	window.location.href = "MAILBOX.com";	
	}else{
		return;
	}
}
/** 修改一个类别信息 **/
function editType(){
	PopDivUp(6);
}

/**上传一个图片到图片库**/
function addNewPhoto(){
	PopDivUp(7);
}







/**===============END:用户事件代码==================**/
function gotoPage(iPageNo)
{  
	with(document.all)
	{  
		var iPage=parseInt(PageNo.innerHTML);
		iPage=(isNaN(iPageNo))?1:((iPageNo<=0)?((iPageNo<0)?--iPage:++iPage):iPageNo);
		if(iPage<=parseInt(totalPage.innerHTML) && iPage>0)
		{		
		location=location.pathname+"?PageNo=" +iPage + "&OrderField=" + document.getElementById("OrderField").value + "&OrderWise=" + document.getElementById("OrderWise").value;
		}
	}
}


/**当Form被提交时候执行**/
function onTheFormSubmit(){
	return true;
}

function OrderBy(strField)
{
	var oWise,strOrderWise;
	oWise=document.getElementById("OrderWise");

	if (document.getElementById("OrderField").value==strField)
	{
		if (oWise.value=="ASC")
			strOrderWise="DESC";
		else
			strOrderWise="ASC";
	}
	else
		strOrderWise="ASC";

	location=location.pathname+"?OrderField=" + strField + "&OrderWise=" + strOrderWise;

}


var parentDivArgs;
var CurrentOpenned;
function PopDivUp(a,cUrl) {
	var sURL;
	var icenter;
	var idialogWidth;
	var idialogHeight;
	var bShowScrollBar;
	var CnTitle;
	var EnTitle;
	var openMode;	//打开方式
	if(a>0){	
		switch(a) {
			//<新增一个相册专辑>
			case   1: if(cUrl!=null) sURL=cUrl; else sURL="./portal/photo/newPhotoLib.jsp";openMode=0; idialogWidth="520px"; idialogHeight="440px"; break;
			//<编辑一个相册专辑>
			case   2: if(cUrl!=null) sURL=cUrl; else sURL="./portal/photo/editPhotoLib.jsp?aid="+TheTableControl.getItem(8); openMode=0; idialogWidth="520px"; idialogHeight="420px"; break;
			//<查询一个企业帐号>
			case   3: if(cUrl!=null) sURL=cUrl; else sURL="./portal/cac/queryGroupAccount.jsp"; openMode=0; idialogWidth="520px"; idialogHeight="360px"; break;
			//<新增一个专辑类别>
			case   5: if(cUrl!=null) sURL=cUrl; else sURL="./portal/photo/newSpecialType.jsp"; openMode=0; idialogWidth="520px"; idialogHeight="360px"; break;
			//<修改一个专辑类别>
			case   6: if(cUrl!=null) sURL=cUrl; else sURL="./portal/photo/editSpecialType.jsp?aid="+TheTableControl.getItem(8); openMode=0; idialogWidth="520px"; idialogHeight="360px"; break;
			//<上传一张图片>
			case   7: if(cUrl!=null) sURL=cUrl; else sURL="./portal/photo/newPhoto.jsp";openMode=0; idialogWidth="520px"; idialogHeight="340px"; break;
	
	
		}
		
		if (document.all) {
			var V6Sorting;
			var strLanguage='';			
			CurrentOpenned = a;
			if (PopDivUp.arguments.length>1){
				strLanguage=PopDivUp.arguments[1];
				sURL = sURL + '&language='+strLanguage;
			}				
			openURL = sURL + getVerString(sURL);							
			switch (openMode){
				case 0:				
					OpenDivDialog(openURL,'',idialogWidth,idialogHeight,"",CnTitle,EnTitle);
					break;
				case 1:
					var leftWidth = (window.screen.width-parseInt(idialogWidth))/2;
					var topHeight = (window.screen.height-parseInt(idialogHeight))/2;
					window.open(openURL,'','resizable=yes,scrollbars=auto,menubar=no,directories=no,toolbar=no,location=no,status=1,center=yes,help=yes,left='+leftWidth+',top='+topHeight+',width='+idialogWidth+',height='+idialogHeight);					
					break;				
			}								
		}	
	}
}

